#ifndef __MESSAGE_DISPATCHER_H__
#define __MESSAGE_DISPATCHER_H__

#include "stdint.h"


typedef struct {
    void* (*init)();
    int (*send_message)(const uint8_t *message,int length);
    int (*receive_message)(uint8_t *buffer, int buffer_size);
} MessageDispatcher_Interface;

#define MESSAGE_DISPATCHER_DEBUG 0


#define DEVICE_ADDRESS 0x01
#define MESSAGE_DEVICE_FUNC_CODE 0x17
#define MESSAGE_HEADER_MAGIC_LENGTH 4

/*接收的消息相关定义*/
#define MESSAGE_RECV_HEADER_LENGTH     12
#define MESSAGE_RECV_SUB_HEADER_LENGTH (MESSAGE_RECV_SUB_HEADER_MAGIC_LENGTH+MESSAGE_RECV_SUB_HEADER_CMD_CHANNEL_LENGTH+MESSAGE_RECV_SUB_HEADER_Cmdlen_LEN)

#define MESSAGE_RECV_SUB_HEADER_MAGIC_LENGTH 4

#define MESSAGE_RECV_SUB_HEADER_CMD_CHANNEL  101
#define MESSAGE_RECV_SUB_HEADER_CMD_CHANNEL_LENGTH 2

#define MESSAGE_RECV_SUB_HEADER_Cmdlen_LEN   2



/*发送消息相关定义*/
#define MESSAGE_SEND_HEADER_LENGTH 4
#define MESSAGE_SEND_SUB_HEADER_LENGTH (MESSAGE_SEND_SUB_HEADER_MAGIC_LENGTH+MESSAGE_SEND_SUB_HEADER_CMD_CHANNEL_LENGTH+MESSAGE_SEND_SUB_HEADER_Cmdlen_LEN)

#define MESSAGE_SEND_SUB_HEADER_MAGIC_LENGTH 4
#define MESSAGE_SEND_SUB_HEADER_CMD_CHANNEL 101
#define MESSAGE_SEND_SUB_HEADER_CMD_CHANNEL_LENGTH 2
#define MESSAGE_SEND_SUB_HEADER_Cmdlen_LEN   2



enum
{
    MESSAGE_CMD_NONE = 0x0,
    MESSAGE_CMD_VERSION = 0x91,
    MESSAGE_CMD_QUERY_SYSTEM = 0x92,
    MESSAGE_CMD_QUERY_PHOTO = 0x93,
    MESSAGE_CMD_QUERY_CONFIG = 0x94,
    MESSAGE_CMD_SET_CONFIG = 0x95,
    MESSAGE_CMD_GET_SELF_CHECK_RESULT = 0x96,
    MESSAGE_CMD_REBOOT = 0x97,
    MESSAGE_CMD_REQUEST_CONNECT = 0x98,

    /*OTA升级相关指令*/
    MESSAGE_CMD_OTA = 0x99,                     /*OTA升级请求包*/

    /*拍照功能*/
    MESSAGE_CMD_TAKE_PHOTO = 0x9C,

    MESSAGE_CMD_OPEN_USB_STREAM = 0x9E,
    MESSAGE_CMD_CLOSE_USB_STREAM = 0x9F,
    
};


int create_message_dispatcher_thread();

#endif
